package com.shd.edanpei.ui.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.CompoundButton;

import com.chad.library.adapter.base.BaseViewHolder;
import com.shd.edanpei.R;
import com.shd.edanpei.base.BaseQuickImageAdapter;
import com.shd.edanpei.bean.NeedBean;


/**
 * Created by mc on 2018/3/12.
 */
public class NeedAdapter extends BaseQuickImageAdapter<NeedBean> {


    public NeedAdapter(Context context) {
        super(context, R.layout.need_item);
    }

    @Override
    protected void convert(BaseViewHolder helper, final NeedBean item) {
        helper.setText(R.id.tv_need_item_name, item.getName());
        CheckBox checkBox = helper.getView(R.id.cb_need_item);
        if (item.isCheck()) {
            checkBox.setChecked(true);
        }
        checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                item.setCheck(isChecked);
            }
        });

    }
}
